<template>
  <div class="app-container">
    <template>
      <div class="hidden-md-and-up">
        <el-alert title="如若不适应手机端操作，建议使用电脑操作" type="warning" />
      </div>
    </template>
    <div class="table-container">
      <div style="padding-bottom:20px; display: flex;">
        <div style="width: 260px;">
          <label>项目名称</label>
          <el-input v-model="search.projectName" size="medium" placeholder="输入关键字搜索" style="width: 160px;" />
        </div>
        <div style="width: 260px;">
          <label>项目编号</label>
          <el-input v-model="search.projectId" size="medium" placeholder="输入关键字搜索" style="width: 160px;" />
        </div>
        <div style="width: 260px;">
          <label>项目类别</label>
          <el-input v-model="search.projectCate" size="medium" placeholder="输入关键字搜索" style="width: 160px;" />
        </div>
        <div style="width: 260px;">
          <label>项目来源单位</label>
          <el-input v-model="search.projectUnit" size="medium" placeholder="输入关键字搜索" style="width: 160px;" />
        </div>
        <div style="width: 260px;">
          <label>项目负责人</label>
          <el-input v-model="search.headName" size="medium" placeholder="输入关键字搜索" style="width: 160px;" />
        </div>
      </div>
      <div style="padding-bottom:20px; display: flex;">
        <div style="width: 220px;">
          <label>项目状态</label>
          <el-select v-model="search.projectState" size="medium" placeholder="请选择" style="width: 160px;" @change="statusChange">
            <el-option label="全部" value="" />
            <el-option label="草稿" value="草稿" />
            <el-option label="在研待院审核" value="在研待院审核" />
            <el-option label="在研待校审核" value="在研待校审核" />
            <el-option label="项目在研退回" value="项目在研退回" />
            <el-option label="项目在研" value="项目在研" />
            <el-option label="结题待院审核" value="结题待院审核" />
            <el-option label="结题待校审核" value="结题待校审核" />
            <el-option label="项目结题退回" value="项目结题退回" />
            <el-option label="项目结题" value="项目结题" />
          </el-select>
        </div>
        <div style="width: 600px; display: flex; align-items: center; gap: 8px; margin-left: 20px;">
          <label>项目开始时间</label>
          <div style="flex: 1">
            <el-date-picker
              v-model="search.startTimeStart"
              type="date"
              placeholder="起始时间"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
              style="width: 100%"
            />
          </div>
          <span style="flex-shrink: 0; margin: 0 4px">-</span>
          <div style="flex: 1">
            <el-date-picker
              v-model="search.startTimeEnd"
              type="date"
              placeholder="结束时间"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
              style="width: 100%"
            />
          </div>
        </div>
        <div style="width: 220px; margin-left: 20px;">
          <label>所属学院</label>
          <el-select
            v-model="search.deptName"
            :loading="deptLoading"
            size="medium"
            placeholder="请选择"
            filterable
            clearable
            style="width: 160px;"
            @focus="fetchDeptData"
          >
            <el-option label="全部" value="" />
            <el-option v-for="item in dept_options" :key="item.deptID" :label="item.deptName" :value="item.deptName" />
          </el-select>
        </div>
        <div style="margin-left: 20px;" />
        <el-button type="primary" size="medium" plain @click="addthesis">项目录入</el-button>
        <el-button type="success" size="medium" plain icon="el-icon-download" @click="excel_dialog = true">导出</el-button>
      </div>
      <el-table
        v-loading="paperListLoading"
        :data="paperList"
        element-loading-text="玩命加载中..."
        border
        fit
      >
        <el-table-column type="selection" align="center" width="55" />
        <!-- <el-table-column align="center" label="序号" width="55">
          <template slot-scope="scope">
            {{ scope.$index+1 }}
          </template>
        </el-table-column> -->
        <el-table-column align="center" label="项目名称" min-width="120">
          <template slot-scope="scope">
            {{ scope.row.projectName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目编号" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.projectId }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目类别" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.projectCate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目来源单位" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.projectUnit }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目负责人" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.headName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目成员" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.memberNames || '暂无' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="合同经费（万元）" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.contractFunds || '暂无' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="到校经费（万元）" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.arrivingFunds || '暂无' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目状态" min-width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.projectState | statusFilter">{{ scope.row.projectState }}</el-tag>
            <el-tag v-if="scope.row.projectState === '项目在研退回' || scope.row.projectState === '项目结题退回'" type="warning">{{ scope.row.reason }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="300">
          <template slot-scope="scope">
            <el-popover
              :ref="`popoverdelete-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认删除本行吗？该操作不可撤销</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="delete_thesis(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <el-popover
              :ref="`popovercommit1-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认提交吗？提交后不可再修改</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popovercommit1-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="commit_thesis1(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <el-popover
              :ref="`popovercommit2-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认提交吗？提交后不可再修改</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popovercommit2-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="commit_thesis2(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <!-- 撤回弹窗 -->
            <el-popover
              :ref="`popoverwithdraw-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认撤回项目吗？</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popoverwithdraw-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="handleWithdrawConfirm(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <el-button
              size="mini"
              @click="open_infoview_dialog(scope.row)"
            >
              编辑
            </el-button>
            <el-button
              v-popover="`popoverdelete-${scope.$index}`"
              size="mini"
              type="danger"
            >
              删除
            </el-button>
            <el-button
              v-popover="`popoverwithdraw-${scope.$index}`"
              size="mini"
              type="info"
              :disabled="false"
            >
              撤回
            </el-button>
            <div style="margin: 10px 0;" />
            <el-button
              v-popover="`popovercommit1-${scope.$index}`"
              size="mini"
              type="success"
            >
              在研
            </el-button>
            <el-button
              v-popover="`popovercommit2-${scope.$index}`"
              size="mini"
              type="success"
            >
              结题
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          background
          :current-page="p1_page"
          :page-sizes="[1,2,3,10, 20, 30, 40]"
          :page-size="p1_size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="p1_total"
          @size-change="p1_sizechange"
          @current-change="p1_currentchange"
        />
        <!-- @size-change="handleSizeChange"
          @current-change="handleCurrentChange" -->
        <!-- 使用了size-change和current-change事件来处理页码大小和当前页变动时候触发的事件。 -->
      </div>
      <el-dialog title="项目录入" :visible.sync="thesis_add_dialog" width="75%" :close-on-click-modal="false">
        <el-form ref="thesis_add_form1" :model="thesis_add_form1" :rules="add_rules" label-position="top" label-width="160px" autocomplete="off">
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="录入人" prop="enteredName">
                <el-input v-model="thesis_add_form1.enteredName" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目名称" prop="projectName">
                <el-input v-model="thesis_add_form1.projectName" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="合同编号" prop="projectId">
                <el-input v-model="thesis_add_form1.projectId" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目类别" prop="projectCate">
                <el-select v-model="thesis_add_form1.projectCate" placeholder="请选择项目类别">
                  <el-option label="自然科学" value="自然科学" />
                  <el-option label="社会科学" value="社会科学" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="合同类型" prop="projectType">
                <el-select v-model="thesis_add_form1.projectType" placeholder="请选择">
                  <el-option label="技术开发类" value="技术开发类" />
                  <el-option label="技术转让类" value="技术转让类" />
                  <el-option label="技术许可类" value="技术许可类" />
                  <el-option label="技术服务类" value="技术服务类" />
                  <el-option label="技术咨询类" value="技术咨询类" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目负责人工号" prop="account">
                <el-autocomplete
                  v-model="thesis_add_form1.account"
                  :fetch-suggestions="querySearchAsync"
                  placeholder="请输入工号搜索"
                  :trigger-on-focus="false"
                  @select="authorIdHandleSelect"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目负责人姓名" prop="headName">
                <el-input
                  v-model="thesis_add_form1.headName"
                  placeholder="仅支持通过工号搜索填充"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="职称" prop="title">
                <el-input v-model="thesis_add_form1.title" />
                <!-- <el-input -->
                <!-- v-model="thesis_add_form1.title"
                  placeholder="仅支持通过工号搜索填充"
                  disabled
                /> -->
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="学历" prop="education">
                <el-select v-model="thesis_add_form1.education" placeholder="请选择">
                  <el-option label="其他" value="其他" />
                  <el-option label="本科" value="本科" />
                  <el-option label="硕士研究生" value="硕士研究生" />
                  <el-option label="博士研究生" value="博士研究生" />
                </el-select>
                <!-- <el-input
                  v-model="thesis_add_form1.education"
                  placeholder="仅支持通过工号搜索填充"
                  disabled
                /> -->
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目来源单位/企业名称" prop="projectUnit">
                <el-input v-model="thesis_add_form1.projectUnit" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="选择来源单位/企业所在省、市" prop="projectSourceUnit">
                <el-cascader
                  v-model="thesis_add_form1.projectSourceUnit"
                  :options="projectSourceUnit_options"
                  :props="{ expandTrigger: 'hover',
                            checkStrictly: true,
                            emitPath: true,
                            value: 'value',
                            label: 'label',
                            children: 'children'
                  }"
                  filterable
                  clearable
                  class="cascader"
                  @change="handleAddFormProjectSourceUnitCascaderChange"
                  @focus="fetchCascadingProjectSourceUnitData"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="来源单位类型" prop="sourceUnitType">
                <el-select v-model="thesis_add_form1.sourceUnitType" placeholder="请选择">
                  <el-option label="民营企业" value="民营企业" />
                  <el-option label="行政机关" value="行政机关" />
                  <el-option label="事业单位" value="事业单位" />
                  <el-option label="国有企业" value="国有企业" />
                  <el-option label="社会组织" value="社会组织" />
                  <el-option label="军队单位" value="军队单位" />
                  <el-option label="其他" value="其他" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="thesis_add_form1.sourceUnitType === '国有企业' || thesis_add_form1.sourceUnitType === '民营企业'" :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item
                v-if="thesis_add_form1.sourceUnitType === '国有企业' || thesis_add_form1.sourceUnitType === '民营企业'"
                label="来源企业/公司分类"
                prop="sourceEnterpriseCategory"
              >
                <el-select v-model="thesis_add_form1.sourceEnterpriseCategory" multiple placeholder="请选择">
                  <el-option label="高新技术企业" value="高新技术企业" />
                  <el-option label="专精特新企业" value="专精特新企业" />
                  <el-option label="新物种企业" value="新物种企业" />
                  <el-option label="规上企业" value="规上企业" />
                  <el-option label="其他" value="其他" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目开始日期" prop="startTime">
                <el-date-picker
                  v-model="thesis_add_form1.startTime"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目结束日期" prop="endTime">
                <el-date-picker
                  v-model="thesis_add_form1.endTime"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="立项日期" prop="approvalTime">
                <el-date-picker
                  v-model="thesis_add_form1.approvalTime"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="立项年度" prop="approvalYear">
                <el-date-picker
                  v-model="thesis_add_form1.approvalYear"
                  type="year"
                  placeholder="选择年"
                  format="yyyy 年"
                  value-format="yyyy年"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="承担二级单位" prop="secondUnit">
                <el-select
                  v-model="thesis_add_form1.secondUnit"
                  placeholder="请选择所属机构(可检索)"
                  filterable
                  clearable
                  @focus="fetchSecondUnitData"
                >
                  <el-option v-for="item in secondUnit_options" :key="item.deptID" :label="item.deptName" :value="item.deptName" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="财务编号" prop="financialNum">
                <el-input v-model="thesis_add_form1.financialNum" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="合同经费(万元)" prop="contractFunds">
                <el-input v-model="thesis_add_form1.contractFunds" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="到校经费(万元)" prop="arrivingFunds">
                <el-input v-model="thesis_add_form1.arrivingFunds" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="服务的国民经济行业" prop="nationalEconomy">
                <el-select
                  v-model="thesis_add_form1.nationalEconomy"
                  :loading="SelectLoading"
                  placeholder="请选择服务的国民经济行业(可检索)"
                  filterable
                  clearable
                  @focus="fetchNationalEconomyData"
                >
                  <el-option v-for="item in nationalEconomy_options" :key="item.id" :label="item.nationalEconomyType" :value="item.nationalEconomyType" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目参与人">
                <el-input :value="thesis_add_form1.projectMembers || thesis_add_form1.projectParticipants" disabled placeholder="仅支持通过成员列表搜索填充" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="协作内容和要求" prop="contentRequirements">
                <el-input v-model="thesis_add_form1.contentRequirements" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="预期成果(结题要求)" prop="expect">
                <el-input v-model="thesis_add_form1.expect" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="预期目标和考核目标" prop="goal">
                <el-input v-model="thesis_add_form1.goal" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="知识产权归属及分享" prop="intellectual">
                <el-input v-model="thesis_add_form1.intellectual" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="工作进度计划" prop="jobPlan">
                <el-input v-model="thesis_add_form1.jobPlan" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="付款计划" prop="payPlan">
                <el-input v-model="thesis_add_form1.payPlan" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="档案编号" prop="archiveNum">
                <el-input v-model="thesis_add_form1.archiveNum" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="学科分类" prop="disciplineClassfi">
                <el-cascader
                  v-model="thesis_add_form1.disciplineClassfi"
                  :options="disciplineClassfi_options"
                  :props="{ expandTrigger: 'hover',
                            emitPath: false
                  }"
                  :loading="SelectLoading"
                  placeholder="请选择学科分类(可检索)"
                  filterable
                  clearable
                  @focus="fetchdisciplineClassfiData"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="活动类型" prop="activityType">
                <el-select
                  v-model="thesis_add_form1.activityType"
                  :loading="SelectLoading"
                  placeholder="请选择活动类型"
                  filterable
                  clearable
                  @focus="fetchactivityTypeData"
                >
                  <el-option v-for="item in activityType_options" :key="item.activityTypeID" :label="item.activityTypeName" :value="item.activityTypeName" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目来源" prop="projectSourse">
                <el-select
                  v-model="thesis_add_form1.projectSourse"
                  :loading="SelectLoading"
                  placeholder="请选择项目来源(可检索)"
                  filterable
                  clearable
                  @focus="fetchprojectSourseData"
                >
                  <el-option v-for="item in projectSourse_options" :key="item.projectSourseID" :label="item.projectSourseName" :value="item.projectSourseName" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="组织形式" prop="organizationForm">
                <el-select
                  v-model="thesis_add_form1.organizationForm"
                  :loading="SelectLoading"
                  placeholder="请选择组织形式"
                  filterable
                  clearable
                  @focus="fetchorganizationFormData"
                >
                  <el-option v-for="item in organizationForm_options" :key="item.organizationFormID" :label="item.organizationFormName" :value="item.organizationFormName" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="合作形式" prop="cooperaForm">
                <el-select v-model="thesis_add_form1.cooperaForm" style="width: 270px;">
                  <el-option label="独立完成" value="独立完成" />
                  <el-option label="与境外机构合作" value="与境外机构合作" />
                  <el-option label="与国内高校合作" value="与国内高校合作" />
                  <el-option label="与国内独立研究机构合作" value="与国内独立研究机构合作" />
                  <el-option label="与境内注册外商独资企业合作" value="与境内注册外商独资企业合作" />
                  <el-option label="与境内注册其他企业合作" value="与境内注册其他企业合作" />
                  <el-option label="其他" value="其他" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="项目的社会经济目标" prop="socialEconomy">
                <el-select
                  v-model="thesis_add_form1.socialEconomy"
                  :loading="SelectLoading"
                  placeholder="请选择项目的社会经济目标(可检索)"
                  filterable
                  clearable
                  @focus="fetchSocialEconomyData"
                >
                  <el-option v-for="item in socialEconomy_options" :key="item.socialEconomyID" :label="item.socialEconomyName" :value="item.socialEconomyName" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="备注" prop="notes">
                <el-input v-model="thesis_add_form1.notes" type="textarea" style="width:300px;" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-popover
            ref="dialog1"
            v-model="visible1"
            placement="top"
            width="160"
          >
            <p>关闭后，已填写的内容会丢失，建议保存为草稿，确定要关闭吗？</p>
            <div style="text-align: right; margin: 0">
              <el-button size="mini" type="text" @click="visible1 = false">取消</el-button>
              <el-button type="primary" size="mini" @click="visible1 = false;thesis_add_dialog = false;">确定</el-button>
            </div>
          </el-popover>
          <el-button v-popover:dialog1>关 闭</el-button>
          <el-tooltip placement="top" effect="light">
            <div slot="content">检查表单是否填写正确<br>若不正确则最终无法提交审核</div>
            <el-button type="primary" plain @click="check_rules('thesis_add_form1')">检 查</el-button>
          </el-tooltip>
          <el-button type="primary" @click="save_add_form1(thesis_add_form1)">保 存</el-button>
        </div>
      </el-dialog>
      <el-dialog title="编辑信息" :visible.sync="infoview_dialog" width="75%">
        <el-collapse v-model="activeNames">
          <el-collapse-item name="1">
            <template slot="title">
              <div class="el-descriptions__title">项目信息</div>
            </template>
            <el-dialog title="项目信息" :visible.sync="thesis_info_dialog" width="60%" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_add_form2" :model="thesis_add_form2" :rules="add_rules" label-position="top" label-width="160px" autocomplete="off">
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="录入人" prop="enteredName">
                      <el-input v-model="thesis_add_form2.enteredName" :disabled="true" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目名称" prop="projectName">
                      <el-input v-model="thesis_add_form2.projectName" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="合同编号" prop="projectId">
                      <el-input v-model="thesis_add_form2.projectId" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目类别" prop="projectCate">
                      <el-select v-model="thesis_add_form2.projectCate" placeholder="请选择项目类别">
                        <el-option label="自然科学" value="自然科学" />
                        <el-option label="社会科学" value="社会科学" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="合同类型" prop="projectType">
                      <el-select v-model="thesis_add_form2.projectType" placeholder="请选择">
                        <el-option label="技术开发类" value="技术开发类" />
                        <el-option label="技术转让类" value="技术转让类" />
                        <el-option label="技术许可类" value="技术许可类" />
                        <el-option label="技术服务类" value="技术服务类" />
                        <el-option label="技术咨询类" value="技术咨询类" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目负责人工号" prop="account">
                      <el-autocomplete
                        v-model="thesis_add_form2.account"
                        :fetch-suggestions="querySearchAsync"
                        placeholder="请输入工号搜索"
                        :trigger-on-focus="false"
                        @select="authorIdHandleSelect"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目负责人姓名" prop="headName">
                      <el-input
                        v-model="thesis_add_form2.headName"
                        placeholder="仅支持通过工号搜索填充"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="职称" prop="title">
                      <el-input v-model="thesis_add_form2.title" />
                      <!-- <el-input
                        v-model="thesis_add_form2.title"
                        placeholder="仅支持通过工号搜索填充"
                        disabled
                      /> -->
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="学历" prop="education">
                      <el-select v-model="thesis_add_form2.education" placeholder="请选择">
                        <el-option label="其他" value="其他" />
                        <el-option label="本科" value="本科" />
                        <el-option label="硕士研究生" value="硕士研究生" />
                        <el-option label="博士研究生" value="博士研究生" />
                      </el-select>
                      <!-- <el-input
                        v-model="thesis_add_form2.education"
                        placeholder="仅支持通过工号搜索填充"
                        disabled
                      /> -->
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目来源单位/企业名称" prop="projectUnit">
                      <el-input v-model="thesis_add_form2.projectUnit" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="选择来源单位/企业所在省、市" prop="projectSourceUnit">
                      <el-cascader
                        v-model="thesis_add_form2.projectSourceUnit"
                        :options="projectSourceUnit_options"
                        :props="{ expandTrigger: 'hover',
                                  checkStrictly: true,
                                  emitPath: true,
                                  value: 'value',
                                  label: 'label',
                                  children: 'children'
                        }"
                        filterable
                        clearable
                        class="cascader"
                        @change="handleAddFormProjectSourceUnitCascaderChange"
                        @focus="fetchCascadingProjectSourceUnitData"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="来源单位类型" prop="sourceUnitType">
                      <el-select v-model="thesis_add_form2.sourceUnitType" placeholder="请输入">
                        <el-option label="民营企业" value="民营企业" />
                        <el-option label="行政机关" value="行政机关" />
                        <el-option label="事业单位" value="事业单位" />
                        <el-option label="国有企业" value="国有企业" />
                        <el-option label="社会组织" value="社会组织" />
                        <el-option label="军队单位" value="军队单位" />
                        <el-option label="其他" value="其他" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="thesis_add_form2.sourceUnitType === '国有企业' || thesis_add_form2.sourceUnitType === '民营企业'" :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item
                      v-if="thesis_add_form2.sourceUnitType === '国有企业' || thesis_add_form2.sourceUnitType === '民营企业'"
                      label="来源企业/公司分类"
                      prop="sourceEnterpriseCategory"
                    >
                      <el-select v-model="thesis_add_form2.sourceEnterpriseCategory" multiple placeholder="请选择">
                        <el-option label="高新技术企业" value="高新技术企业" />
                        <el-option label="专精特新企业" value="专精特新企业" />
                        <el-option label="新物种企业" value="新物种企业" />
                        <el-option label="规上企业" value="规上企业" />
                        <el-option label="其他" value="其他" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目开始日期" prop="startTime">
                      <el-date-picker
                        v-model="thesis_add_form2.startTime"
                        type="date"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目结束日期" prop="endTime">
                      <el-date-picker
                        v-model="thesis_add_form2.endTime"
                        type="date"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="立项日期" prop="approvalTime">
                      <el-date-picker
                        v-model="thesis_add_form2.approvalTime"
                        type="date"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="立项年度" prop="approvalYear">
                      <el-date-picker
                        v-model="thesis_add_form2.approvalYear"
                        type="year"
                        placeholder="选择年"
                        format="yyyy 年"
                        value-format="yyyy年"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="承担二级单位" prop="secondUnit">
                      <el-select
                        v-model="thesis_add_form2.secondUnit"
                        placeholder="请选择所属机构(可检索)"
                        filterable
                        clearable
                        @focus="fetchSecondUnitData"
                      >
                        <el-option v-for="item in secondUnit_options" :key="item.deptID" :label="item.deptName" :value="item.deptName" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="财务编号" prop="financialNum">
                      <el-input v-model="thesis_add_form2.financialNum" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="合同经费(万元)" prop="contractFunds">
                      <el-input v-model="thesis_add_form2.contractFunds" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="到校经费(万元)" prop="arrivingFunds">
                      <el-input v-model="thesis_add_form2.arrivingFunds" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="服务的国民经济行业" prop="nationalEconomy">
                      <el-select
                        v-model="thesis_add_form2.nationalEconomy"
                        :loading="SelectLoading"
                        placeholder="请选择服务的国民经济行业(可检索)"
                        filterable
                        clearable
                        @focus="fetchNationalEconomyData"
                      >
                        <el-option v-for="item in nationalEconomy_options" :key="item.id" :label="item.nationalEconomyType" :value="item.nationalEconomyType" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目参与人">
                      <el-input :value="thesis_add_form2.projectMembers || thesis_add_form2.projectParticipants" disabled placeholder="仅支持通过成员列表搜索填充" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="协作内容和要求" prop="contentRequirements">
                      <el-input v-model="thesis_add_form2.contentRequirements" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="预期成果(结题要求)" prop="expect">
                      <el-input v-model="thesis_add_form2.expect" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="预期目标和考核目标" prop="goal">
                      <el-input v-model="thesis_add_form2.goal" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="知识产权归属及分享" prop="intellectual">
                      <el-input v-model="thesis_add_form2.intellectual" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="工作进度计划" prop="jobPlan">
                      <el-input v-model="thesis_add_form2.jobPlan" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="付款计划" prop="payPlan">
                      <el-input v-model="thesis_add_form2.payPlan" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="档案编号" prop="archiveNum">
                      <el-input v-model="thesis_add_form2.archiveNum" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="学科分类" prop="disciplineClassfi">
                      <el-cascader
                        v-model="thesis_add_form2.disciplineClassfi"
                        :options="disciplineClassfi_options"
                        :props="{ expandTrigger: 'hover',
                                  emitPath: false
                        }"
                        :loading="SelectLoading"
                        placeholder="请选择学科分类(可检索)"
                        filterable
                        clearable
                        @focus="fetchdisciplineClassfiData"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="活动类型" prop="activityType">
                      <el-select
                        v-model="thesis_add_form2.activityType"
                        :loading="SelectLoading"
                        placeholder="请选择活动类型"
                        filterable
                        clearable
                        @focus="fetchactivityTypeData"
                      >
                        <el-option v-for="item in activityType_options" :key="item.activityTypeID" :label="item.activityTypeName" :value="item.activityTypeName" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目来源" prop="projectSourse">
                      <el-select
                        v-model="thesis_add_form2.projectSourse"
                        :loading="SelectLoading"
                        placeholder="请选择项目来源(可检索)"
                        filterable
                        clearable
                        @focus="fetchprojectSourseData"
                      >
                        <el-option v-for="item in projectSourse_options" :key="item.projectSourseID" :label="item.projectSourseName" :value="item.projectSourseName" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="组织形式" prop="organizationForm">
                      <el-select
                        v-model="thesis_add_form2.organizationForm"
                        :loading="SelectLoading"
                        placeholder="请选择组织形式"
                        filterable
                        clearable
                        @focus="fetchorganizationFormData"
                      >
                        <el-option v-for="item in organizationForm_options" :key="item.organizationFormID" :label="item.organizationFormName" :value="item.organizationFormName" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="合作形式" prop="cooperaForm">
                      <el-select v-model="thesis_add_form2.cooperaForm" style="width: 270px;">
                        <el-option label="独立完成" value="独立完成" />
                        <el-option label="与境外机构合作" value="与境外机构合作" />
                        <el-option label="与国内高校合作" value="与国内高校合作" />
                        <el-option label="与国内独立研究机构合作" value="与国内独立研究机构合作" />
                        <el-option label="与境内注册外商独资企业合作" value="与境内注册外商独资企业合作" />
                        <el-option label="与境内注册其他企业合作" value="与境内注册其他企业合作" />
                        <el-option label="其他" value="其他" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="项目的社会经济目标" prop="socialEconomy">
                      <el-select
                        v-model="thesis_add_form2.socialEconomy"
                        :loading="SelectLoading"
                        placeholder="请选择项目的社会经济目标(可检索)"
                        filterable
                        clearable
                        @focus="fetchSocialEconomyData"
                      >
                        <el-option v-for="item in socialEconomy_options" :key="item.socialEconomyID" :label="item.socialEconomyName" :value="item.socialEconomyName" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="备注" prop="notes">
                      <el-input v-model="thesis_add_form2.notes" type="textarea" style="width:300px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-popover
                  ref="dialog2"
                  v-model="visible2"
                  placement="top"
                  width="160"
                >
                  <p>关闭后，已填写的内容会丢失，建议保存为草稿，确定要关闭吗？</p>
                  <div style="text-align: right; margin: 0">
                    <el-button size="mini" type="text" @click="visible2 = false">取消</el-button>
                    <el-button type="primary" size="mini" @click="visible2 = false;thesis_info_dialog = false;">确定</el-button>
                  </div>
                </el-popover>
                <el-button v-popover:dialog2>关 闭</el-button>
                <el-tooltip placement="top" effect="light">
                  <div slot="content">检查表单是否填写正确<br>若不正确则最终无法提交审核</div>
                  <el-button type="primary" plain @click="check_rules('thesis_add_form2')">检 查</el-button>
                </el-tooltip>
                <el-button type="primary" @click="save_add_form2(thesis_add_form2)">保 存</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_thesis_info_dialog(infoview1)">编辑信息</el-button>
            </div>
            <el-descriptions :column="2" size="medium" border :label-style="{width:'25%'}" :content-style="{width:'25%'}">
              <el-descriptions-item label="横向项目ID">
                {{ infoview1.tregistrationID }}
              </el-descriptions-item>
              <el-descriptions-item label="录入人">
                {{ infoview1.enteredName }}
              </el-descriptions-item>
              <el-descriptions-item label="录入日期">
                {{ infoview1.enteredDate }}
              </el-descriptions-item>
              <el-descriptions-item label="项目名称">
                {{ infoview1.projectName }}
              </el-descriptions-item>
              <el-descriptions-item label="项目编号">
                {{ infoview1.projectId }}
              </el-descriptions-item>
              <el-descriptions-item label="项目类别">
                {{ infoview1.projectCate }}
              </el-descriptions-item>
              <el-descriptions-item label="项目类型">
                {{ infoview1.projectType }}
              </el-descriptions-item>
              <el-descriptions-item label="来源单位类型">
                {{ infoview1.sourceUnitType }}
              </el-descriptions-item>
              <el-descriptions-item v-if="infoview1.sourceUnitType === '国有企业' || thesis_add_form1.sourceUnitType === '民营企业'" label="来源企业/公司分类">
                {{ infoview1.sourceEnterpriseCategory }}
              </el-descriptions-item>
              <el-descriptions-item label="项目来源单位">
                {{ infoview1.projectUnit }}
              </el-descriptions-item>
              <el-descriptions-item label="来源单位/企业所在省、市">
                {{ infoview1.projectSourceUnit }}
              </el-descriptions-item>
              <el-descriptions-item label="项目负责人">
                {{ infoview1.headName }}
              </el-descriptions-item>
              <el-descriptions-item label="项目开始日期">
                {{ infoview1.startTime }}
              </el-descriptions-item>
              <el-descriptions-item label="项目结束日期">
                {{ infoview1.endTime }}
              </el-descriptions-item>
              <el-descriptions-item label="立项日期">
                {{ infoview1.approvalTime }}
              </el-descriptions-item>
              <el-descriptions-item label="立项年度">
                {{ infoview1.approvalYear }}
              </el-descriptions-item>
              <el-descriptions-item label="档案编号">
                {{ infoview1.archiveNum }}
              </el-descriptions-item>
              <el-descriptions-item label="财务项目号">
                {{ infoview1.archiveNum }}
              </el-descriptions-item>
              <el-descriptions-item label="到校经费(万元)">
                {{ infoview1.arrivingFunds }}
              </el-descriptions-item>
              <el-descriptions-item label="合同经费(万元)">
                {{ infoview1.contractFunds }}
              </el-descriptions-item>
              <el-descriptions-item label="服务的国民经济行业">
                {{ infoview1.nationalEconomy }}
              </el-descriptions-item>
              <el-descriptions-item label="项目参与人">
                {{ infoview1.projectParticipants }}
              </el-descriptions-item>
              <el-descriptions-item label="协作内容和要求">
                {{ infoview1.contentRequirements }}
              </el-descriptions-item>
              <el-descriptions-item label="预期成果(结题要求)">
                {{ infoview1.expect }}
              </el-descriptions-item>
              <el-descriptions-item label="预期目标和考核目标">
                {{ infoview1.goal }}
              </el-descriptions-item>
              <el-descriptions-item label="知识产权归属及分享">
                {{ infoview1.intellectual }}
              </el-descriptions-item>
              <el-descriptions-item label="工作进度计划">
                {{ infoview1.jobPlan }}
              </el-descriptions-item>
              <el-descriptions-item label="付款计划">
                {{ infoview1.payPlan }}
              </el-descriptions-item>
              <el-descriptions-item label="学科分类">
                {{ infoview1.disciplineClassfi }}
              </el-descriptions-item>
              <el-descriptions-item label="活动类型">
                {{ infoview1.activityType }}
              </el-descriptions-item>
              <el-descriptions-item label="项目来源">
                {{ infoview1.projectSourse }}
              </el-descriptions-item>
              <el-descriptions-item label="组织形式">
                {{ infoview1.organizationForm }}
              </el-descriptions-item>
              <el-descriptions-item label="合作形式">
                {{ infoview1.cooperaForm }}
              </el-descriptions-item>
              <el-descriptions-item label="项目的社会经济目标">
                {{ infoview1.socialEconomy }}
              </el-descriptions-item>
              <el-descriptions-item label="承担二级单位">
                {{ infoview1.secondUnit }}
              </el-descriptions-item>
              <el-descriptions-item label="职称">
                {{ infoview1.title }}
              </el-descriptions-item>
              <el-descriptions-item label="学历">
                {{ infoview1.education }}
              </el-descriptions-item>
              <el-descriptions-item label="项目状态">
                <el-tag :type="infoview1.projectState | statusFilter">{{ infoview1.projectState }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="退回原因">
                {{ infoview1.reason }}
              </el-descriptions-item>
              <el-descriptions-item label="分数">
                <el-tag type="">{{ infoview1.score }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="备注">
                {{ infoview1.notes }}
              </el-descriptions-item>
            </el-descriptions>
          </el-collapse-item>
          <el-collapse-item name="2">
            <template slot="title">
              <div class="el-descriptions__title">
                <span style="color: red;">*</span>量化分数
              </div>
            </template>
            <div style="margin-bottom: 10px;">
              <span>分数计算规则参考：</span>
              <el-link type="primary" :href="$FILE_PATH+'/file/量化细则图/科研项目积分规则可视化.pdf'" target="_blank">科研项目计分规则可视化</el-link>
              <br>
              <span>官方文件：</span>
              <el-link type="primary" :href="$FILE_PATH+'/file/量化细则图/湖北师范大学科研工作量化管理办法（修订版）.pdf'" target="_blank">湖北师范大学科研工作量化管理办法（修订版）</el-link>
              <el-switch
                v-model="thesis_source_form.manualScoreMode"
                active-text="手动填分"
                inactive-text="自动计分"
                style="float: right; margin-right: 20px;"
                @change="handleScoreModeChange"
              />
            </div>
            <!-- 自动计分模式 -->
            <el-form v-if="!thesis_source_form.manualScoreMode" ref="thesis_source_form" :inline="true" :model="thesis_source_form" :rules="source_rules" label-width="80px" style="margin-left: 0;">
              <el-form-item label="选择类型" prop="source_cascader_value">
                <el-cascader
                  v-model="thesis_source_form.source_cascader_value"
                  :options="source_options"
                  :props="{ expandTrigger: 'hover' }"
                  filterable
                  clearable
                  :show-all-levels="true"
                  class="cascader"
                  @change="cascaderhandleChange"
                  @focus="fetchCascadingData"
                />
              </el-form-item>
              <el-form-item label="到账经费" prop="funds">
                <el-input v-model="thesis_source_form.funds" placeholder="单位(万元)" style="width: 100px;" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="addSource">提交</el-button>
              </el-form-item>
            </el-form>
            <!-- 手动填分模式 -->
            <el-form v-if="thesis_source_form.manualScoreMode" ref="thesis_source_form" :inline="true" :model="thesis_source_form" :rules="manual_source_rules" label-width="80px" style="margin-left: 0;">
              <el-form-item label="最终分数" prop="finalValue">
                <el-input v-model="thesis_source_form.finalValue" placeholder="请直接填入分数" style="width: 200px;" />
              </el-form-item>
              <el-form-item label="算分详情" prop="Note">
                <el-input
                  v-model="thesis_source_form.Note"
                  type="textarea"
                  :rows="3"
                  placeholder="请填入算分依据"
                  :maxlength="500"
                  show-word-limit
                  style="width: 700px; resize: vertical;"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="addSource">提交</el-button>
              </el-form-item>
            </el-form>
            <el-table
              v-loading="sourceListLoading"
              :data="sourceList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column v-if="!thesis_source_form.manualScoreMode" align="center" label="一级类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.projectType2 }}
                </template>
              </el-table-column>
              <el-table-column v-if="!thesis_source_form.manualScoreMode" align="center" label="到账经费(万元)" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.funds }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="最终得分" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.finalValue }}
                </template>
              </el-table-column>
              <el-table-column v-if="thesis_source_form.manualScoreMode" align="center" label="算分详情" min-width="300">
                <template slot-scope="scope">
                  {{ scope.row.Note }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_source(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="3">
            <template slot="title">
              <div class="el-descriptions__title">
                <span style="color: red;">*</span>成员列表
              </div>
            </template>
            <el-dialog width="60%" :title="innerdialog1_title" :visible.sync="thesis_author_innerdialog" append-to-body :close-on-click-modal="false">
              <author-search :target-form="thesis_author_form" style="margin-left: 10px;" @author-selected="handleAuthorSelected" />
              <el-tabs v-model="thesis_author_form_activeName" stretch>
                <el-tab-pane v-if="innerdialog1_add || thesis_author_form_activeName === 'first'" label="校内教师" name="first" />
                <el-tab-pane v-if="innerdialog1_add || thesis_author_form_activeName === 'second'" label="校外作者" name="second" />
                <el-tab-pane v-if="innerdialog1_add || thesis_author_form_activeName === 'third'" label="学生" name="third" />
              </el-tabs>
              <el-form ref="thesis_author_form" :model="thesis_author_form" :rules="author_rules" label-position="top" label-width="160px" style="margin-top: 20px;">
                <el-form-item v-if="thesis_author_form_activeName === 'first'" label="工号" prop="userAccount">
                  <el-autocomplete
                    v-model="thesis_author_form.userAccount"
                    :fetch-suggestions="querySearchAsync"
                    placeholder="请输入工号搜索"
                    :trigger-on-focus="false"
                    @select="authorHandleSelect"
                  />
                </el-form-item>
                <el-form-item label="姓名" prop="name">
                  <el-input
                    v-model="thesis_author_form.name"
                    :placeholder="thesis_author_form_activeName === 'first' ? '仅支持通过工号搜索填充' : '请输入姓名'"
                    :disabled="thesis_author_form_activeName === 'first'"
                  />
                </el-form-item>
                <el-form-item label="所属机构" prop="dept">
                  <el-input
                    v-model="thesis_author_form.dept"
                    :placeholder="thesis_author_form_activeName === 'first' ? '仅支持通过工号搜索填充' : '请输入所属机构'"
                    :disabled="thesis_author_form_activeName === 'first'"
                  />
                </el-form-item>
                <el-form-item label="作者排名" prop="ranking">
                  <el-select v-model="thesis_author_form.ranking" placeholder="请选择">
                    <el-option
                      v-for="n in 10"
                      :key="n"
                      :label="n.toString()"
                      :value="n.toString()"
                    />
                  </el-select>
                </el-form-item>
                <el-form-item label="考核系数（应在0-100之间）" prop="assessment">
                  <el-input v-model="thesis_author_form.assessment" />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="thesis_author_innerdialog = false">取 消</el-button>
                <el-button v-if="innerdialog1_add" type="primary" @click="add_thesis_author">确 定</el-button>
                <el-button v-if="!innerdialog1_add" type="primary" @click="edit_thesis_author">确 定</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_add_author_innerdialog">添加成员列表</el-button>
            </div>
            <el-table
              v-loading="paperAuthorListLoading"
              :data="paperAuthorList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column align="center" label="工号" min-width="100">
                <template slot-scope="scope">
                  {{ (scope.row.authortype === '校内教师' || scope.row.peopleType === '校内教师' || scope.row.authorType === '校内教师' || !scope.row.authorType) && scope.row.userAccount ? scope.row.userAccount : '无' }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="姓名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.name }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="所属院系" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dept }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="排名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.ranking }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="考核系数" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.assessment }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="个人得分" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.pscore }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_author(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="open_edit_author_innerdialog(scope.$index, scope.row)"
                  >
                    编辑
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="4">
            <template slot="title">
              <div class="el-descriptions__title">到账经费</div>
            </template>
            <el-dialog width="60%" :title="innerdialog2_title" :visible.sync="thesis_DZfunds_innerdialog" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_DZfunds_form" :model="thesis_DZfunds_form" :rules="thesis_DZfunds_rules" label-position="top" label-width="160px">
                <el-form-item label="到账编号" prop="dzfundsNum">
                  <el-input v-model="thesis_DZfunds_form.dzfundsNum" />
                </el-form-item>
                <el-form-item label="到账金额(万元)" prop="dzfundsAmount">
                  <el-input v-model="thesis_DZfunds_form.dzfundsAmount" />
                </el-form-item>
                <el-form-item label="经费来源" prop="fundsSours">
                  <el-input v-model="thesis_DZfunds_form.fundsSours" />
                </el-form-item>
                <el-form-item label="到账日期" prop="dzfundsDate">
                  <el-date-picker
                    v-model="thesis_DZfunds_form.dzfundsDate"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="thesis_DZfunds_innerdialog = false">取 消</el-button>
                <el-button v-if="innerdialog2_add" type="primary" @click="add_thesis_DZfunds">确 定</el-button>
                <el-button v-if="!innerdialog2_add" type="primary" @click="edit_thesis_DZfunds">确 定</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_add_DZfunds_innerdialog">添加到账记录</el-button>
            </div>
            <el-table
              v-loading="paperDZfundsListLoading"
              :data="paperDZfundsList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" width="55" />
              <el-table-column align="center" label="到账编号" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dzfundsNum }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="到账金额(万元)" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dzfundsAmount }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="经费来源" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.fundsSours }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="到账日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dzfundsDate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="上传时间" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.uploadTime }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_DZfunds(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="open_edit_DZfunds_innerdialog(scope.$index, scope.row)"
                  >
                    编辑
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="5">
            <template slot="title">
              <div class="el-descriptions__title">支出经费</div>
            </template>
            <el-dialog width="60%" :title="innerdialog3_title" :visible.sync="thesis_ZCfunds_innerdialog" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_ZCfunds_form" :model="thesis_ZCfunds_form" :rules="thesis_ZCfunds_rules" label-position="top" label-width="160px">
                <el-form-item label="支出编号" prop="zcfundsNum">
                  <el-input v-model="thesis_ZCfunds_form.zcfundsNum" />
                </el-form-item>
                <el-form-item label="支出金额(万元)" prop="zcfundsAmount">
                  <el-input v-model="thesis_ZCfunds_form.zcfundsAmount" />
                </el-form-item>
                <el-form-item label="支出类别" prop="zcfundsType">
                  <el-input v-model="thesis_ZCfunds_form.zcfundsType" />
                </el-form-item>
                <el-form-item label="支出日期" prop="zcfundsDate">
                  <el-date-picker
                    v-model="thesis_ZCfunds_form.zcfundsDate"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="thesis_ZCfunds_innerdialog = false">取 消</el-button>
                <el-button v-if="innerdialog3_add" type="primary" @click="add_thesis_ZCfunds">确 定</el-button>
                <el-button v-if="!innerdialog3_add" type="primary" @click="edit_thesis_ZCfunds">确 定</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_add_ZCfunds_innerdialog">添加支出记录</el-button>
            </div>
            <el-table
              v-loading="paperZCfundsListLoading"
              :data="paperZCfundsList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" width="55" />
              <el-table-column align="center" label="支出编号" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.zcfundsNum }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="支出金额(万元)" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.zcfundsAmount }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="支出类别" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.zcfundsType }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="支出日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.zcfundsDate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="上传时间" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.uploadTime }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_ZCfunds(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="open_edit_ZCfunds_innerdialog(scope.$index, scope.row)"
                  >
                    编辑
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="6">
            <template slot="title">
              <div class="el-descriptions__title">附件信息</div>
            </template>
            <div class="upload">
              <div class="uploadBox">
                <el-upload
                  ref="upload"
                  class="upload-demo"
                  drag
                  :action="$BACK_PATH+'/fileUpload/uploadfileTranProject'"
                  accept=".jpg,.png,.doc,.docx,.xls,.xlsx,.pdf"
                  :on-success="handleFileSuccess"
                  :show-file-list="true"
                  :headers="{ 'X-Token': $store.getters.token }"
                  multiple
                  :disabled="roles.includes('院级教师') && (infoview1.projectState === '在研待院审核' || infoview1.projectState === '在研待校审核' || infoview1.projectState === '结题待院审核' || infoview1.projectState === '结题待校审核' || infoview1.projectState === '结题')"
                  :before-upload="beforeFileUpload"
                  @click.native="handleUploadClick"
                >
                  <i class="el-icon-upload" />
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png/doc/xls/pdf/docx/xlsx文件，且不超过50MB</div>
                </el-upload>
              </div>
              <div class="uploadText">
                <el-alert
                  title="注意事项"
                  type="warning"
                  :closable="false"
                  :show-icon="true"
                >
                  <p>1、一次上传一个文件，上传完成的文件会在下方表格中显示</p>
                  <p>2、在下方表格中您可以进行下载和删除操作</p>
                  <p>3、本模块您需要上传的附件有“XXXXX”、“XXXXXX”</p>
                  <p>4、需上传的必要附件为两个，即①盖章版合同pdf版；②到账凭证或发票。其他补充文件暂时不作数量限制或要求.</p>
                </el-alert>
              </div>
            </div>
            <el-table
              v-loading="fileListLoading"
              :data="fileList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" width="55" />
              <el-table-column align="left" label="文件名称" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filename }}
                </template>
              </el-table-column>
              <el-table-column align="left" label="文件大小" min-width="150">
                <template slot-scope="scope">
                  <span v-if="scope.row.filesize / 1024 / 1024 < 1">{{ (scope.row.filesize / 1024).toFixed(2) + 'KB' }}</span>
                  <span v-else>{{ (scope.row.filesize / 1024 / 1024).toFixed(2) + 'MB' }}</span>
                </template>
              </el-table-column>
              <el-table-column align="left" label="上传时间" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filedate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="deleteFile(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="downloadFile(scope.row)"
                  >
                    下载
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="7">
            <template slot="title">
              <div class="el-descriptions__title">审核记录</div>
            </template>
            <el-table
              v-loading="paperAuditListLoading"
              :data="paperAuditList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" label="序号" width="55" />
              <el-table-column align="center" label="审核员职位" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerRole }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核员姓名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerName }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="项目状态变化" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.statusChange }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核意见" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditOpinion }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核时间" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerTime }}
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
        </el-collapse>
        <div slot="footer" class="dialog-footer">
          <el-button @click="infoview_dialog = false">关 闭</el-button>
        </div>
      </el-dialog>
      <el-dialog title="导出excel" :visible.sync="excel_dialog" width="60%">
        <el-alert
          title="请选择需要导出的数据"
          type="success"
          description="选择的数据为表头，未选择的数据将不会导出"
          :closable="false"
        />
        <div style="margin: 15px;">
          <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
          <div style="margin: 15px 0;" />
          <el-checkbox-group v-model="check_fields" @change="handleCheckedFieldsChange">
            <el-checkbox v-for="field in fields_list" :key="field" :label="field">{{ field }}</el-checkbox>
          </el-checkbox-group>
        </div>
        <el-alert
          title="请选择其他筛选条件"
          type="success"
          description="选择导出数据的筛选条件以及时间范围的信息，精准导出您所需要的信息"
          :closable="false"
        />
        <div style="padding-top:20px; display: flex;margin-left: 20px;">
          <div style="width: 220px; margin-right: 20px;">
            <label>项目状态</label>
            <el-select v-model="exportData.projectState" size="medium" placeholder="请选择" style="width: 160px;" @change="statusChange">
              <el-option label="全部" value="" />
              <el-option label="草稿" value="草稿" />
              <el-option label="在研待院审核" value="在研待院审核" />
              <el-option label="在研待校审核" value="在研待校审核" />
              <el-option label="项目在研退回" value="项目在研退回" />
              <el-option label="项目在研" value="项目在研" />
              <el-option label="结题待院审核" value="结题待院审核" />
              <el-option label="结题待校审核" value="结题待校审核" />
              <el-option label="项目结题退回" value="项目结题退回" />
              <el-option label="项目结题" value="项目结题" />
            </el-select>
          </div>
          <div style="width: 500px; display: flex; align-items: center; gap: 8px">
            <label>项目到账时间</label>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.dzfundsDateStart"
                type="date"
                placeholder="起始时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
            <span style="flex-shrink: 0; margin: 0 4px">-</span>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.dzfundsDateEnd"
                type="date"
                placeholder="结束时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
          </div>
        </div>
        <div style="padding-top:20px; display: flex; margin-left: 20px;">
          <div style="width: 500px; display: flex; align-items: center; gap: 8px;margin-right: 20px;">
            <label>项目开始时间</label>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.startTimeStart"
                type="date"
                placeholder="起始时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
            <span style="flex-shrink: 0; margin: 0 4px">-</span>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.startTimeEnd"
                type="date"
                placeholder="结束时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
          </div>
          <div style="width: 260px;">
            <label>导出条数</label>
            <el-input v-model="exportData.exportNum" size="medium" style="width: 160px;" />
          </div>
        </div>
        <div style="padding-top:20px; display: flex; margin-left: 20px;">
          <div style="width: 500px; display: flex; align-items: center; gap: 8px;margin-right: 20px;">
            <label>项目结束时间</label>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.endTimeStart"
                type="date"
                placeholder="起始时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
            <span style="flex-shrink: 0; margin: 0 4px">-</span>
            <div style="flex: 1">
              <el-date-picker
                v-model="exportData.endTimeEnd"
                type="date"
                placeholder="结束时间"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="excel_dialog = false">关 闭</el-button>
          <download-excel
            style="display:inline-block !important;margin-left:10px;"
            :data="EXCEL.DetailsForm"
            :fields="EXCEL.json_fields"
            :header="EXCEL.title"
            type="xls"
            name="产学研横向项目导出数据.xls"
            :fetch="createExportData"
            :before-generate="startDownload"
            :before-finish="finishDownload"
          >
            <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
            <el-button type="success" plain>确认导出</el-button>
          </download-excel>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { getNationalEconomyData, getSecondUnitData, getCascadingProjectSourceUnitData, getExportData, getUserHorizontals, thesis_add, thesis_add2, thesis_delete, thesis_commit1, thesis_commit2, thesis_withdraw, get_thesis_author, thesis_DZfunds_edit, thesis_author_add, get_thesis_DZfunds, thesis_DZfunds_add, thesis_author_delete, thesis_author_edit, get_file, file_add, file_delete, thesis_DZfunds_delete, get_thesis_ZCfunds, thesis_ZCfunds_add, thesis_ZCfunds_edit, thesis_ZCfunds_delete, getCascadingData, addQulification, getQulification, deleteQulification, GetHxProjectDTOById } from '@/api/horizontal'
import { get_thesis_Audit } from '@/api/audit'
import { getProjectSourse, getOrganizationForm, getActivityType, getDisciplineClassfi, getSocialEconomy, getDepts } from '@/api/system'
import { getUserByAccount } from '@/api/user'
import { Message, Loading } from 'element-ui'
import { mapGetters } from 'vuex'
import AuthorSearch from '@/components/AuthorSearch'

export default {
  name: 'ThesisView',
  components: {
    AuthorSearch
  },
  filters: {
    statusFilter(status) {
      const statusMap = {
        草稿: 'info',
        项目在研: 'success',
        项目结题: 'success',
        在研待院审核: '',
        在研待校审核: '',
        结题待院审核: '',
        结题待校审核: '',
        项目在研退回: 'danger',
        项目结题退回: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      socialEconomy_options: [],
      organizationForm_options: [],
      projectSourse_options: [],
      activityType_options: [],
      disciplineClassfi_options: [],
      SelectLoading: false,
      projectCate_options: [],
      thesis_add_dialog: false,
      thesis_info_dialog: false,
      thesis_author_innerdialog: false,
      thesis_DZfunds_innerdialog: false,
      thesis_ZCfunds_innerdialog: false,
      infoview_dialog: false,
      visible1: false,
      visible2: false,
      // 用于跟踪按钮状态的对象
      committedButtons: {},
      thesis_add_form1: {
        disciplineClassfi: '',
        activityType: '',
        projectSourse: '',
        organizationForm: '',
        cooperaForm: '',
        socialEconomy: '',
        projectParticipants: '',
        projectFlag: 3,
        education: '',
        projectSourceUnit: '',
        projectSourceUnitId: [],
        sourceUnitType: '',
        sourceEnterpriseCategory: [],
        secondUnit: '',
        nationalEconomyId: [],
        nationalEconomy: '',
        approvalMaterial: '',
        approvalTime: '',
        approvalYear: '',
        archiveNum: '',
        arrivingFunds: '',
        birthdate: '',
        contentRequirements: '',
        contractFunds: '',
        endTime: '',
        entered: '',
        enteredName: '',
        enteredDate: '',
        expect: '',
        financialNum: '',
        goal: '',
        head: '',
        headName: '',
        account: '',
        intellectual: '',
        jobPlan: '',
        notes: '',
        payPlan: '',
        projectCate: '',
        projectId: '',
        projectMembers: '',
        projectName: '',
        projectState: '',
        projectType: '',
        projectUnit: '',
        reason: '',
        startTime: '',
        status: '',
        title: '',
        tregistrationID: '',
        unit: ''
      },
      thesis_add_form2: {
        disciplineClassfi: '',
        activityType: '',
        projectSourse: '',
        organizationForm: '',
        cooperaForm: '',
        socialEconomy: '',
        projectParticipants: '',
        education: '',
        projectSourceUnit: '',
        projectSourceUnitId: [],
        sourceUnitType: '',
        sourceEnterpriseCategory: '',
        secondUnit: '',
        nationalEconomyId: [],
        nationalEconomy: '',
        approvalMaterial: '',
        approvalTime: '',
        approvalYear: '',
        archiveNum: '',
        arrivingFunds: '',
        birthdate: '',
        contentRequirements: '',
        contractFunds: '',
        endTime: '',
        entered: '',
        enteredName: '',
        enteredDate: '',
        expect: '',
        financialNum: '',
        goal: '',
        head: '',
        headName: '',
        account: '',
        intellectual: '',
        jobPlan: '',
        notes: '',
        payPlan: '',
        projectCate: '',
        projectId: '',
        projectMembers: '',
        projectName: '',
        projectState: '',
        projectType: '',
        projectUnit: '',
        reason: '',
        startTime: '',
        status: '',
        title: '',
        tregistrationID: '',
        unit: ''
      },
      add_rules: {
        disciplineClassfi: [
          { required: true, message: '学科分类不能为空', trigger: 'blur' }
        ],
        activityType: [
          { required: true, message: '活动类型不能为空', trigger: 'blur' }
        ],
        projectSourse: [
          { required: true, message: '项目来源不能为空', trigger: 'blur' }
        ],
        organizationForm: [
          { required: true, message: '组织形式不能为空', trigger: 'blur' }
        ],
        cooperaForm: [
          { required: true, message: '合作形式不能为空', trigger: 'blur' }
        ],
        socialEconomy: [
          { required: true, message: '项目的社会经济目标不能为空', trigger: 'blur' }
        ],
        projectParticipants: [],
        account: [
          { required: true, message: '工号不能为空', trigger: 'blur' }
        ],
        education: [
          { required: true, message: '学历不能为空', trigger: 'blur' }
        ],
        projectSourceUnitId: [
          { required: true, message: '项目来源单位不能为空', trigger: 'blur' }
        ],
        projectSourceUnit: [
          { required: true, message: '选择来源单位/企业所在省、市不能为空', trigger: 'blur' }
        ],
        sourceUnitType: [
          { required: true, message: '来源单位类型不能为空', trigger: 'blur' }
        ],
        sourceEnterpriseCategory: [
          { required: true, message: '来源企业类别不能为空', trigger: 'blur' }
        ],
        secondUnit: [
          { required: true, message: '承担二级单位不能为空', trigger: 'blur' }
        ],
        nationalEconomyId: [
          { required: true, message: '国民经济领域ID不能为空', trigger: 'blur' }
        ],
        nationalEconomy: [
          { required: true, message: '服务的国民经济行业不能为空', trigger: 'blur' }
        ],
        approvalMaterial: [],
        approvalTime: [
          { required: true, message: '立项时间不能为空', trigger: 'blur' }
        ],
        approvalYear: [
          { required: true, message: '立项年度不能为空', trigger: 'blur' }
        ],
        archiveNum: [],
        arrivingFunds: [
          { required: true, message: '到账经费不能为空', trigger: 'blur' }
        ],
        birthdate: [],
        contentRequirements: [],
        contractFunds: [
          { required: true, message: '合同经费不能为空', trigger: 'blur' }
        ],
        endTime: [
          { required: true, message: '结束时间不能为空', trigger: 'blur' }
        ],
        startTime: [
          { required: true, message: '开始时间不能为空', trigger: 'blur' }
        ],
        entered: [],
        enteredDate: [],
        expect: [],
        financialNum: [
          { required: true, message: '财务编号不能为空', trigger: 'blur' }
        ],
        goal: [],
        head: [
          { required: true, message: '负责人不能为空', trigger: 'blur' }
        ],
        headName: [
          { required: true, message: '项目负责人姓名不能为空', trigger: 'blur' }
        ],
        intellectual: [],
        jobPlan: [],
        notes: [],
        payPlan: [],
        projectCate: [
          { required: true, message: '项目类别不能为空', trigger: 'blur' }
        ],
        projectId: [
          { required: true, message: '项目编号不能为空', trigger: 'blur' }
        ],
        projectMembers: [],
        projectName: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
        projectState: [],
        projectType: [
          { required: true, message: '合同类型不能为空', trigger: 'blur' }
        ],
        projectUnit: [
          { required: true, message: '项目来源单位不能为空', trigger: 'blur' }
        ],
        reason: [],
        status: [],
        title: [
          { required: true, message: '标题不能为空', trigger: 'blur' }
        ],
        tregistrationID: [],
        unit: [
          { required: true, message: '所属单位不能为空', trigger: 'blur' }
        ],
        funds: [
          { required: true, message: '经费不能为空', trigger: 'blur' },
          {
            pattern: /^([1-9]\d*|0)(\.\d{1,2})?$/,
            message: '请输入有效数字',
            trigger: ['blur', 'change']
          }
        ]
      },
      thesis_author_form: {
        assessment: '',
        dept: '',
        name: '',
        ranking: '',
        authorType: '校内教师',
        tranprojecauthorid: '',
        tregistrationid: '',
        userAccount: ''
      },
      thesis_author_form_activeName: 'first',
      author_rules: {
        name: [
          { required: true, message: '姓名不能为空', trigger: 'blur' }
        ],
        userAccount: [
          { required: true, message: '工号不能为空', trigger: 'blur' }
        ],
        dept: [
          { required: true, message: '所属机构不能为空', trigger: 'blur' }
        ],
        authorType: [
          { required: true, message: '作者类型不能为空', trigger: 'blur' }
        ],
        ranking: [
          { required: true, message: '作者排名不能为空', trigger: 'change' }
        ],
        assessment: [
          { required: true, message: '考核系数不能为空', trigger: 'blur' },
          {
            pattern: /^([1-9]\d*|0)(\.\d{1,2})?$/,
            message: '请输入有效数字',
            trigger: ['blur', 'change']
          }
        ]
      },
      thesis_DZfunds_rules: {
        dzfundsNum: [
          { required: true, message: '到账经费编号不能为空', trigger: 'blur' }
        ],
        dzfundsAmount: [
          { required: true, message: '到账经费金额不能为空', trigger: 'blur' },
          {
            pattern: /^([1-9]\d*|0)(\.\d{1,2})?$/,
            message: '请输入有效数字',
            trigger: ['blur', 'change']
          }
        ],
        fundsSours: [
          { required: true, message: '经费来源不能为空', trigger: 'blur' }
        ],
        dzfundsDate: [
          { required: true, message: '到账日期不能为空', trigger: 'change' }
        ]
      },
      thesis_DZfunds_form: {
        dzfundsAmount: '',
        dzfundsDate: '',
        dzfundsID: '',
        dzfundsNum: '',
        fundsSours: '',
        tregistrationID: '',
        uploadTime: ''
      },
      thesis_ZCfunds_rules: {
        zcfundsNum: [
          { required: true, message: '支出经费编号不能为空', trigger: 'blur' }
        ],
        zcfundsAmount: [
          { required: true, message: '支出经费金额不能为空', trigger: 'blur' },
          {
            pattern: /^([1-9]\d*|0)(\.\d{1,2})?$/,
            message: '请输入有效数字',
            trigger: ['blur', 'change']
          }
        ],
        zcfundsType: [
          { required: true, message: '支出类型不能为空', trigger: 'blur' }
        ],
        zcfundsDate: [
          { required: true, message: '支出日期不能为空', trigger: 'change' }
        ]
      },
      thesis_ZCfunds_form: {
        dzfundsAmount: '',
        dzfundsDate: '',
        dzfundsID: '',
        dzfundsNum: '',
        fundsSours: '',
        tregistrationID: '',
        uploadTime: ''
      },
      paperList: [],
      paperListLoading: false,
      p1_size: 10,
      p1_total: 0,
      p1_page: 1,
      status2: '',
      paperAuthorList: [],
      paperAuthorListLoading: false,
      innerdialog1_title: '新增成员列表',
      innerdialog1_add: true,
      paperDZfundsList: [],
      paperDZfundsListLoading: false,
      innerdialog2_title: '添加到账记录',
      innerdialog2_add: true,
      paperZCfundsList: [],
      paperZCfundsListLoading: false,
      innerdialog3_title: '添加支出记录',
      innerdialog3_add: true,
      paperAuditList: [],
      paperAuditListLoading: false,
      authorValue: [],
      authorOptions: [],
      infoview1: {
        score: '',
        approvalMaterial: '',
        approvalTime: '',
        approvalYear: '',
        archiveNum: '',
        arrivingFunds: '',
        birthdate: '',
        contentRequirements: '',
        contractFunds: '',
        endTime: '',
        entered: '',
        enteredDate: '',
        expect: '',
        financialNum: '',
        goal: '',
        head: '',
        headName: '',
        account: '',
        intellectual: '',
        jobPlan: '',
        notes: '',
        payPlan: '',
        projectCate: '',
        projectId: '',
        projectMembers: '',
        projectName: '',
        projectState: '',
        projectType: '',
        projectUnit: '',
        reason: '',
        startTime: '',
        status: '',
        title: '',
        tregistrationID: '',
        unit: ''
      },
      activeNames: ['1', '2', '3', '4', '5', '6', '7'],
      excel_dialog: false,
      all_fields: {
        'ID': 'tregistrationID',
        '录入人': 'entered',
        '录入日期': 'enteredDate',
        '项目名称': 'projectName',
        '合同编号': 'projectId',
        '项目类别': 'projectCate',
        '合同类型': 'projectType',
        '项目负责人工号': 'account',
        '项目负责人姓名': 'headName',
        '职称': 'title',
        '学历': 'education',
        '项目来源单位/企业名称': 'projectUnit',
        '来源单位/企业所在省、市': 'projectSourceUnit',
        '来源单位类型': 'sourceUnitType',
        '项目开始日期': 'startTime',
        '项目结束日期': 'endTime',
        '立项日期': 'approvalTime',
        '立项年度': 'approvalYear',
        '承担二级单位': 'secondUnit',
        '财务编号': 'financialNum',
        '合同经费(万元)': 'contractFunds',
        '到校经费(万元)': 'arrivingFunds',
        '到账编号': 'dzfundsNum',
        '到账金额(万元)': 'dzfundsAmount',
        '经费来源': 'fundsSours',
        '到账日期': 'dzfundsDate',
        '服务的国民经济行业': 'nationalEconomy',
        '项目参与人': 'projectParticipants',
        '项目成员': 'projectMembers',
        '量化分数': 'score',
        '协作内容和要求': 'contentRequirements',
        '预期成果(结题要求)': 'expect',
        '预期目标和考核目标': 'goal',
        '知识产权归属及分享': 'intellectual',
        '工作进度计划': 'jobPlan',
        '付款计划': 'payPlan',
        '档案编号': 'archiveNum',
        '学科分类': 'disciplineClassfi',
        '活动类型': 'activityType',
        '项目来源': 'projectsourse',
        '组织形式': 'organizationForm',
        '合作形式': 'cooperaForm',
        '项目的社会经济目标': 'socialEconomy',
        '备注': 'notes',
        '项目状态': 'projectState'
      },
      fields_list: [
        '项目名称',
        '合同编号',
        '项目类别',
        '合同类型',
        '项目负责人姓名',
        '项目来源单位/企业名称',
        '立项年度',
        '合同经费(万元)',
        'ID',
        '录入人',
        '录入日期',
        '项目负责人工号',
        '职称',
        '学历',
        '来源单位/企业所在省、市',
        '来源单位类型',
        '项目开始日期',
        '项目结束日期',
        '立项日期',
        '承担二级单位',
        '财务编号',
        '到校经费(万元)',
        '到账编号',
        '到账金额(万元)',
        '经费来源',
        '到账日期',
        '服务的国民经济行业',
        '项目参与人',
        '项目成员',
        '量化分数',
        '协作内容和要求',
        '预期成果(结题要求)',
        '预期目标和考核目标',
        '知识产权归属及分享',
        '工作进度计划',
        '付款计划',
        '档案编号',
        '学科分类',
        '活动类型',
        '项目来源',
        '组织形式',
        '合作形式',
        '项目的社会经济目标',
        '备注',
        '项目状态',
        '申请状态'
      ],
      check_fields: [],
      checkAll: false,
      isIndeterminate: false,
      EXCEL: {
        title: '横向项目',
        json_fields: null,
        DetailsForm: null
      },
      fileList: [],
      fileListLoading: false,
      fileForm: {
        tregistrationID: '',
        filedate: '',
        fileid: '',
        filename: '',
        filesize: '',
        fileurl: ''
      },
      source_options: [],
      projectSourceUnit_options: [],
      secondUnit_options: [],
      nationalEconomy_options: [],
      dept_options: [],
      deptLoading: false,
      firstchoice: true,
      sourceCascaderLoading: null,
      sourceListLoading: false,
      sourceList: [],
      source_rules: {
        source_cascader_value: [
          { required: true, message: '请选择类型', trigger: 'change' }
        ],
        funds: [
          { required: true, message: '请输入到账经费', trigger: 'blur' }
        ]
      },
      // 手动填分模式的验证规则
      manual_source_rules: {
        finalValue: [
          { required: true, message: '请输入分数', trigger: 'blur' }
        ],
        Note: [
          { required: true, message: '请填写算分详情', trigger: 'blur' }
        ]
      },
      thesis_source_form: {
        manualScoreMode: false,
        source_cascader_value: [], // 联级选择
        discipline: '',
        finalValue: 0,
        funds: '',
        instructive: '',
        projectID: '',
        projectQualificationID: '',
        projectType1: '',
        projectType2: '',
        type1ID: 2,
        type2ID: 0,
        Note: ''
      },
      search: {
        projectName: '',
        projectSourse: '',
        projectId: '',
        projectCate: '',
        projectUnit: '',
        headName: '',
        projectState: '',
        startTimeStart: '',
        startTimeEnd: '',
        deptName: ''
      },
      exportData: {
        dzfundsDateEnd: '',
        dzfundsDateStart: '',
        endTimeEnd: '',
        endTimeStart: '',
        exportNum: '',
        projectFlag: 3,
        projectState: '',
        startTimeEnd: '',
        startTimeStart: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'uid',
      'roles',
      'name'
    ]),
    MyPaperPost() {
      return {
        pageNum: this.p1_page,
        pageSize: this.p1_size,
        ...this.search,
        projectFlag: 3
      }
    }
  },
  watch: {
    thesis_author_form_activeName(newVal) {
      // 只在新增模式下清空表单，编辑模式保留数据
      if (this.innerdialog1_add) {
        this.resetForm('thesis_author_form')
        this.thesis_author_form.userAccount = ''
      }
      // 根据当前激活的标签设置人员类型
      if (newVal === 'first') {
        this.thesis_author_form.authorType = '校内教师'
      } else if (newVal === 'second') {
        this.thesis_author_form.authorType = '校外作者'
      } else {
        this.thesis_author_form.authorType = '学生'
      }
    },
    search: {
      handler() {
        this.paperListLoading = true
        clearTimeout(this.searchTimeout)
        this.searchTimeout = setTimeout(() => {
          this.fetchPaperData()
          this.paperListLoading = false
        }, 1500)
      },
      deep: true // 启用深度监视，可监听对象内部属性变化
    }
  },
  created() {
    this.fetchPaperData()
    this.fetchCascadingProjectSourceUnitData()
    this.fetchSecondUnitData()
    this.fetchNationalEconomyData()
  },
  methods: {
    handleAuthorSelected(author) {
      // 可以在这里处理选中作者后的额外逻辑
      // 作者选择处理
    },
    fetchSocialEconomyData() {
      this.SelectLoading = true
      getSocialEconomy().then(response => {
        if (response.code === 200) {
          this.socialEconomy_options = response.data
          this.SelectLoading = false
        }
      })
    },
    fetchorganizationFormData() {
      this.SelectLoading = true
      getOrganizationForm().then(response => {
        if (response.code === 200) {
          this.organizationForm_options = response.data
          this.SelectLoading = false
        }
      })
    },
    fetchprojectSourseData() {
      this.SelectLoading = true
      getProjectSourse().then(response => {
        if (response.code === 200) {
          let data = response.data
          const otherItem = data.find(item => item.projectSourseName === '其他')
          if (otherItem) {
            data = data.filter(item => item.projectSourseName !== '其他')
            data.unshift(otherItem)
          }
          this.projectSourse_options = data
          this.SelectLoading = false
        }
      })
    },
    fetchactivityTypeData() {
      this.SelectLoading = true
      getActivityType().then(response => {
        if (response.code === 200) {
          this.activityType_options = response.data
          this.SelectLoading = false
        }
      })
    },
    // 获取学院列表
    fetchDeptData() {
      if (this.dept_options.length === 0) {
        this.deptLoading = true
        getDepts().then(response => {
          if (response.code === 200) {
            this.dept_options = response.data
            this.deptLoading = false
          }
        })
      }
    },
    // 学科分类下拉框
    fetchdisciplineClassfiData() {
      this.SelectLoading = true
      getDisciplineClassfi().then(response => {
        const disciplineClassfiData = response.data
        this.disciplineClassfi_options = this.convertToCascaderData_disciplineClassfi(disciplineClassfiData)
        // this.SelectLoading = false
      }).catch(() => {
        this.SelectLoading = false
      })
    },
    convertToCascaderData_disciplineClassfi(data) {
      const map = {}
      data.forEach(item => {
        if (!map[item.papertype1]) {
          map[item.papertype1] = {
            value: item.papertype1,
            label: item.papertype1,
            children: []
          }
        }
        map[item.papertype1].children.push({
          value: item.papertype2,
          label: item.papertype2
        })
      })
      return Object.values(map)
    },
    handleScoreModeChange(value) {
      this.thesis_source_form.manualScoreMode = value
      this.thesis_source_form.type2ID = ''
      this.thesis_source_form.Note = ''
      this.thesis_source_form.funds = ''
      this.thesis_source_form.finalValue = 0
    },
    // 递归查找树形结构中的节点并收集所有层级label
    findSelectedOptionWithPath(options, values, path = [], level = 0) {
      // 如果已经遍历完所有级联层级或没有更多选项
      if (level >= values.length || !options) return null
      const currentValue = values[level]
      for (const option of options) {
        const currentPath = [...path, option.label]
        if (option.value === currentValue) {
          // 如果是最后一级，返回找到的选项和路径
          if (level === values.length - 1) {
            return { option, path: currentPath }
          }
          // 否则继续查找下一级
          const found = this.findSelectedOptionWithPath(
            option.children,
            values,
            currentPath,
            level + 1
          )
          if (found) return found
        }
      }
      return null
    },
    // 通用级联选择处理函数（存储完整路径）
    handleCascaderChange(values, options, targetField, form = 'thesis_add_form1') {
      if (values && values.length > 0 && options) {
        const result = this.findSelectedOptionWithPath(options, values)
        this[form][targetField] = result?.path.join('/') || ''
      } else {
        this[form][targetField] = ''
      }
    },
    // 新增-项目来源单位级联变化
    handleAddFormProjectSourceUnitCascaderChange(value) {
      this.handleCascaderChange(value, this.projectSourceUnit_options, 'projectSourceUnit')
    },
    // 新增-国民经济行业级联变化
    handleAddFormNationalEconomyUnitCascaderChange(value) {
      this.handleCascaderChange(value, this.nationalEconomy_options, 'nationalEconomy')
    },
    // 编辑-项目来源单位级联变化
    handleEditFormProjectSourceUnitCascaderChange(value) {
      this.handleCascaderChange(value, this.projectSourceUnit_options, 'projectSourceUnit', 'thesis_add_form2')
    },
    // 编辑-国民经济行业级联变化
    handleEditFormNationalEconomyUnitCascaderChange(value) {
      this.handleCascaderChange(value, this.nationalEconomy_options, 'nationalEconomy', 'thesis_add_form2')
    },
    fetchPaperData() {
      this.paperListLoading = true
      getUserHorizontals(this.MyPaperPost).then(response => {
        if (response.code === 200) {
          this.paperList = response.data.list
          this.p1_total = response.data.total
          this.paperListLoading = false
          // 为每个项目获取成员数据
          this.paperList.forEach(project => {
            this.fetchProjectMembers(project)
          })
        }
      })
    },
    buildFilteredMemberNames(members, leaderName, leaderAccount) {
      if (!Array.isArray(members) || members.length === 0) {
        return '暂无'
      }
      const filtered = members.filter(member => {
        const sameName = leaderName && member.name === leaderName
        const sameAccount = leaderAccount && (member.account === leaderAccount || member.userAccount === leaderAccount)
        return !(sameName || sameAccount)
      })
      return filtered.length > 0 ? filtered.map(member => member.name).join('、') : '暂无'
    },
    fetchProjectMembers(project) {
      get_thesis_author(project.tregistrationID).then(response => {
        const members = response.code === 200 && Array.isArray(response.data) ? response.data : []
        const memberNames = this.buildFilteredMemberNames(members, project.headName, project.account || project.head)
        const index = this.paperList.indexOf(project)
        if (index !== -1) {
          this.$set(this.paperList[index], 'memberNames', memberNames)
        } else {
          project.memberNames = memberNames
        }
      }).catch(() => {
        const index = this.paperList.indexOf(project)
        if (index !== -1) {
          this.$set(this.paperList[index], 'memberNames', '暂无')
        } else {
          project.memberNames = '暂无'
        }
      })
    },
    statusChange() {
      this.fetchPaperData()
    },
    p1_sizechange(newsize) {
      this.p1_size = newsize
      this.p1_page = 1
      this.fetchPaperData()
    },
    p1_currentchange(newpage) {
      this.p1_page = newpage
      this.fetchPaperData()
    },
    filterTag(value, row) {
      return row.status === value
    },
    resetForm(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
    },
    check_rules(formName) {
      // 只校验必填项
      const form = this.$refs[formName]
      if (!form) {
        Message.error('表单引用不存在')
        return
      }

      // 修复：获取并显示第一个错误信息
      form.validate((valid, invalidFields) => {
        if (valid) {
          Message.success('表单填写正确！')
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return
            }
          }
          Message.error('表单数据有误，请检查')
        }
      })
    },
    addthesis() {
      this.thesis_add_dialog = true
      this.resetForm('thesis_add_form1')
      this.thesis_add_form1.enteredName = this.name
    },
    save_add_form1(formdata) {
      // 修复：获取并显示第一个错误信息
      this.$refs.thesis_add_form1.validate((valid, invalidFields) => {
        if (valid) {
          formdata.entered = this.uid
          thesis_add(formdata).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_add_dialog = false
              this.fetchPaperData()
            }
          })
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return false
            }
          }
          Message.error('表单数据有误，请检查')
          return false
        }
      })
    },
    open_thesis_info_dialog(data) {
      this.thesis_info_dialog = true
      this.resetForm('thesis_add_form2')
      this.thesis_add_form2 = JSON.parse(JSON.stringify(data))
      // 确保sourceEnterpriseCategory是数组格式并正确处理
      if (this.thesis_add_form2.sourceEnterpriseCategory) {
        // 如果是包含数组格式的字符串，尝试解析
        if (typeof this.thesis_add_form2.sourceEnterpriseCategory === 'string' &&
            this.thesis_add_form2.sourceEnterpriseCategory.includes('[')) {
          try {
            this.thesis_add_form2.sourceEnterpriseCategory = JSON.parse(this.thesis_add_form2.sourceEnterpriseCategory)
          } catch (e) {
            console.error('解析sourceEnterpriseCategory失败:', e)
            // 如果解析失败但字符串中包含企业类别关键词，手动转换为数组
            const categories = ['高新技术企业', '专精特新企业', '新物种企业', '规上企业', '其他']
            const result = []
            categories.forEach(cat => {
              if (this.thesis_add_form2.sourceEnterpriseCategory.includes(cat)) {
                result.push(cat)
              }
            })
            this.thesis_add_form2.sourceEnterpriseCategory = result
          }
        // 如果是字符串但不包含数组格式，按逗号或其他分隔符分割
        } else if (typeof this.thesis_add_form2.sourceEnterpriseCategory === 'string') {
          this.thesis_add_form2.sourceEnterpriseCategory = this.thesis_add_form2.sourceEnterpriseCategory.split(/[,,]/).map(item => item.trim()).filter(item => item)
        // 确保是数组类型
        } else if (!Array.isArray(this.thesis_add_form2.sourceEnterpriseCategory)) {
          this.thesis_add_form2.sourceEnterpriseCategory = [this.thesis_add_form2.sourceEnterpriseCategory]
        }
      } else {
        this.thesis_add_form2.sourceEnterpriseCategory = []
      }
      // 处理projectSourceUnit字段，确保它在绑定到级联选择器之前是正确的格式
      if (this.thesis_add_form2.projectSourceUnit && typeof this.thesis_add_form2.projectSourceUnit === 'string') {
        // 为级联选择器创建一个临时的ID数组，从projectSourceUnit字符串中提取
        // 注意：这里不直接修改projectSourceUnit，而是在数据加载后通过findSelectedOptionWithPath来匹配
        const sourceUnitArray = this.thesis_add_form2.projectSourceUnit.split('/').map(item => item.trim()).filter(item => item)
        if (!this.projectSourceUnit_options || this.projectSourceUnit_options.length === 0) {
          this.fetchCascadingProjectSourceUnitData()
        }
        this.$nextTick(() => {
          const findMatchingValues = (options, labels, level = 0) => {
            if (level >= labels.length || !options) return null
            const currentLabel = labels[level]
            for (const option of options) {
              if (option.label === currentLabel) {
                if (level === labels.length - 1) {
                  return [option.value]
                }
                const found = findMatchingValues(option.children, labels, level + 1)
                if (found) {
                  return [option.value, ...found]
                }
              }
            }
            return null
          }
          const matchingValues = findMatchingValues(this.projectSourceUnit_options, sourceUnitArray)
          if (matchingValues) {
            this.thesis_add_form2.projectSourceUnit = matchingValues
          }
        })
      }
      // 项目类别检查
    },
    save_add_form2(formdata) {
      // 修复：获取并显示第一个错误信息
      this.$refs.thesis_add_form2.validate((valid, invalidFields) => {
        if (valid) {
          thesis_add2(formdata).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_info_dialog = false
              this.fetchPaperData()
              this.fetchOneData()
            }
          })
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return false
            }
          }
          Message.error('表单数据有误，请检查')
          return false
        }
      })
    },
    delete_thesis(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_delete(row.tregistrationID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetchPaperData()
        }
      })
    },
    commit_thesis1(index, row) {
      this.$refs[`popovercommit1-${index}`].doClose()
      thesis_commit1(row.tregistrationID).then(response => {
        if (response.code === 200) {
          Message.success('提交成功')
          this.fetchPaperData()
        }
      })
    },
    commit_thesis2(index, row) {
      this.$refs[`popovercommit2-${index}`].doClose()
      thesis_commit2(row.tregistrationID).then(response => {
        if (response.code === 200) {
          Message.success('提交成功')
          this.fetchPaperData()
        }
      })
    },
    // 撤回项目（统一接口）
    handleWithdrawConfirm(index, row) {
      // 先关闭弹窗
      this.$refs[`popoverwithdraw-${index}`].doClose()
      // 然后调用撤回方法
      this.withdraw_thesis(index, row)
    },
    withdraw_thesis(index, row) {
      console.log('===== 撤回操作调试 =====')
      console.log('项目状态:', row.projectState)
      console.log('项目ID:', row.tregistrationID)
      thesis_withdraw(row.tregistrationID).then(response => {
        console.log('撤回API响应:', response)
        if (response && response.code === 200) {
          this.$message.success('撤回成功')
          this.fetchPaperData()
        } else {
          console.error('撤回失败,非200响应:', response)
          this.$message.error('撤回失败，请稍后重试')
        }
      })
    },
    fetch_thesis_author() {
      return new Promise((resolve) => {
        this.paperAuthorListLoading = true
        get_thesis_author(this.thesis_author_form.tregistrationid).then(response => {
          this.paperAuthorListLoading = false
          if (response.code === 200) {
            // 显示所有成员（包含项目负责人），与my_horizontal保持一致
            this.paperAuthorList = Array.isArray(response.data) ? response.data : []
          } else {
            this.paperAuthorList = []
          }
          this.syncInfoviewParticipants()
          resolve()
        }).catch(() => {
          this.paperAuthorListLoading = false
          this.paperAuthorList = []
          this.syncInfoviewParticipants()
          resolve()
        })
      })
    },
    syncInfoviewParticipants() {
      if (!this.infoview1) return
      const leaderName = this.infoview1.headName
      const leaderAccount = this.infoview1.account || this.infoview1.head
      const participantNames = this.buildFilteredMemberNames(this.paperAuthorList, leaderName, leaderAccount)
      this.infoview1.projectParticipants = participantNames
      this.infoview1.projectMembers = participantNames
      this.infoview1.memberNames = participantNames
    },
    open_thesis_author_innerdialog() {
      this.thesis_author_innerdialog = true
      this.resetForm('thesis_author_form')
    },
    open_add_author_innerdialog() {
      // 先设置新增模式标志，确保 watch 能正确判断
      this.innerdialog1_add = true
      this.innerdialog1_title = '新增成员列表'
      // 重置到校内教师标签页
      this.thesis_author_form_activeName = 'first'
      this.open_thesis_author_innerdialog()
    },
    open_edit_author_innerdialog(index, row) {
      // 先设置标签页，确保正确的字段能够渲染
      if (row.authorType === '校内教师') {
        this.thesis_author_form_activeName = 'first'
      } else if (row.authorType === '校外作者') {
        this.thesis_author_form_activeName = 'second'
      } else if (row.authorType === '学生') {
        this.thesis_author_form_activeName = 'third'
      } else {
        // 默认显示校内教师
        this.thesis_author_form_activeName = 'first'
      }
      // 再设置对话框状态和标题
      this.innerdialog1_title = '编辑作者'
      this.innerdialog1_add = false
      this.thesis_author_innerdialog = true

      // 使用 $nextTick 确保标签页和字段已渲染后再赋值
      this.$nextTick(() => {
        this.thesis_author_form = JSON.parse(JSON.stringify(row))
        // 清除验证状态
        if (this.$refs.thesis_author_form) {
          this.$refs.thesis_author_form.clearValidate()
        }
      })
    },
    querySearchAsync(queryString, cb) {
      getUserByAccount(queryString).then(response => {
        if (response.code === 200) {
          var results = []
          response.data.forEach(item => {
            const value = JSON.parse(
              JSON.stringify(item).replace(/account/g, 'value')
            )
            results.push(value)
          })
          clearTimeout(this.timeout)
          this.timeout = setTimeout(() => {
            cb(results)
          }, 3000 * Math.random())
        }
      })
    },
    authorHandleSelect(item) {
      this.thesis_author_form.name = item.name
      this.thesis_author_form.dept = item.dept
    },
    authorIdHandleSelect(item) {
      this.thesis_add_form1.head = item.uid
      this.thesis_add_form1.headName = item.name
      // this.thesis_add_form1.title = item.title || ''
      // this.thesis_add_form1.education = item.education || ''
      // // 编辑页面也使用这个方法
      // this.thesis_add_form2.head = item.uid
      // this.thesis_add_form2.headName = item.name
      // this.thesis_add_form2.title = item.title || ''
      // this.thesis_add_form2.education = item.education || ''
    },
    authorIdHandleSelect2(item) {
      this.thesis_add_form2.head = item.uid
      this.thesis_add_form2.headName = item.name
      // this.thesis_add_form2.title = item.title || ''
      // this.thesis_add_form2.education = item.education || ''
    },
    add_thesis_author() {
      this.$refs.thesis_author_form.validate(valid => {
        if (valid) {
          thesis_author_add(this.thesis_author_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_author_innerdialog = false
              this.fetch_thesis_author()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    edit_thesis_author() {
      this.$refs.thesis_author_form.validate(valid => {
        if (valid) {
          thesis_author_edit(this.thesis_author_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_author_innerdialog = false
              this.fetch_thesis_author()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    delete_thesis_author(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_author_delete(row.tranprojecauthorid).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetch_thesis_author()
        }
      })
    },
    fetch_thesis_DZfunds() {
      this.paperDZfundsListLoading = true
      get_thesis_DZfunds(this.thesis_DZfunds_form.tregistrationID).then(response => {
        if (response.code === 200) {
          this.paperDZfundsList = response.data
          this.paperDZfundsListLoading = false
        }
      })
    },
    open_thesis_DZfunds_innerdialog() {
      this.thesis_DZfunds_innerdialog = true
      this.resetForm('thesis_DZfunds_form')
    },
    open_add_DZfunds_innerdialog() {
      this.open_thesis_DZfunds_innerdialog()
      this.innerdialog2_title = '添加到账记录'
      this.innerdialog2_add = true
    },
    open_edit_DZfunds_innerdialog(index, row) {
      this.open_thesis_DZfunds_innerdialog()
      this.innerdialog2_title = '编辑到账记录'
      this.thesis_DZfunds_form = JSON.parse(JSON.stringify(row))
      this.innerdialog2_add = false
    },
    add_thesis_DZfunds() {
      this.$refs.thesis_DZfunds_form.validate(valid => {
        if (valid) {
          thesis_DZfunds_add(this.thesis_DZfunds_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_DZfunds_innerdialog = false
              this.fetch_thesis_DZfunds()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    edit_thesis_DZfunds() {
      this.$refs.thesis_DZfunds_form.validate(valid => {
        if (valid) {
          thesis_DZfunds_edit(this.thesis_DZfunds_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_DZfunds_innerdialog = false
              this.fetch_thesis_DZfunds()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    delete_thesis_DZfunds(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_DZfunds_delete(row.dzfundsID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetch_thesis_DZfunds()
        }
      })
    },
    fetch_thesis_ZCfunds() {
      this.paperZCfundsListLoading = true
      get_thesis_ZCfunds(this.thesis_ZCfunds_form.tregistrationID).then(response => {
        if (response.code === 200) {
          this.paperZCfundsList = response.data
          this.paperZCfundsListLoading = false
        }
      })
    },
    open_thesis_ZCfunds_innerdialog() {
      this.thesis_ZCfunds_innerdialog = true
      this.resetForm('thesis_ZCfunds_form')
    },
    open_add_ZCfunds_innerdialog() {
      this.open_thesis_ZCfunds_innerdialog()
      this.innerdialog3_title = '添加支出记录'
      this.innerdialog3_add = true
    },
    open_edit_ZCfunds_innerdialog(index, row) {
      this.open_thesis_ZCfunds_innerdialog()
      this.innerdialog3_title = '编辑支出记录'
      this.thesis_ZCfunds_form = JSON.parse(JSON.stringify(row))
      this.innerdialog3_add = false
    },
    add_thesis_ZCfunds() {
      this.$refs.thesis_ZCfunds_form.validate(valid => {
        if (valid) {
          thesis_ZCfunds_add(this.thesis_ZCfunds_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_ZCfunds_innerdialog = false
              this.fetch_thesis_ZCfunds()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    edit_thesis_ZCfunds() {
      this.$refs.thesis_ZCfunds_form.validate(valid => {
        if (valid) {
          thesis_ZCfunds_edit(this.thesis_ZCfunds_form).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_ZCfunds_innerdialog = false
              this.fetch_thesis_ZCfunds()
            }
          })
        } else {
          Message.error('请填写完整信息')
          return false
        }
      })
    },
    delete_thesis_ZCfunds(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_ZCfunds_delete(row.zcfundsID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetch_thesis_ZCfunds()
        }
      })
    },
    fetch_thesis_Audit() {
      this.paperAuditListLoading = true
      get_thesis_Audit(this.infoview1.tregistrationID).then(response => {
        if (response.code === 200) {
          this.paperAuditList = response.data
          this.paperAuditListLoading = false
        }
      })
    },
    fetchOneData() {
      GetHxProjectDTOById(this.infoview1.tregistrationID).then(response => {
        if (response.code === 200) {
          this.infoview1 = response.data
          // 将项目成员信息同步到编辑表单中
          this.thesis_add_form2.projectMembers = response.data.projectMembers || ''
          // 同时更新项目负责人信息
          this.thesis_add_form2.head = response.data.head || ''
          this.thesis_add_form2.headName = response.data.headName || ''
          this.thesis_add_form2.account = response.data.account || ''
        }
      })
    },
    open_infoview_dialog(row) {
      this.infoview_dialog = true
      this.infoview1.tregistrationID = row.tregistrationID
      this.thesis_author_form.tregistrationid = row.tregistrationID
      // 先获取项目详情，然后再获取成员列表，成员列表展示全部成员
      GetHxProjectDTOById(this.infoview1.tregistrationID).then(response => {
        if (response.code === 200) {
          this.infoview1 = response.data
          // 将项目成员信息同步到编辑表单中
          this.thesis_add_form2.projectMembers = response.data.projectMembers || ''
          // 同时更新项目负责人信息
          this.thesis_add_form2.head = response.data.head || ''
          this.thesis_add_form2.headName = response.data.headName || ''
          this.thesis_add_form2.account = response.data.account || ''
          // 获取项目详情后再获取成员列表
          this.fetch_thesis_author()
        }
      })
      this.thesis_DZfunds_form.tregistrationID = row.tregistrationID
      this.fetch_thesis_DZfunds()
      this.thesis_ZCfunds_form.tregistrationID = row.tregistrationID
      this.fetch_thesis_ZCfunds()
      this.fileForm.tregistrationID = row.tregistrationID
      this.fetchFileData()
      this.resetForm('thesis_source_form')
      this.thesis_source_form.projectID = row.tregistrationID
      this.fetchSourceData()
      this.fetch_thesis_Audit()
    },
    // 以下时数据导出
    handleCheckAllChange(val) {
      this.check_fields = val ? this.fields_list : []
      this.isIndeterminate = false
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    handleCheckedFieldsChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.fields_list.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.fields_list.length
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    async createExportData() {
      return await getExportData(this.exportData).then(response => {
        if (response.code === 200) {
          if (response.data.length === 0) {
            Message.warning('返回数据为空，导出失败！')
          }
          this.loadingInstance.close()
          return response.data
        }
      })
    },
    startDownload() {
      this.excel_dialog = false
      this.loadingInstance = Loading.service({ text: '正在导出...' })
    },
    finishDownload() {
      setTimeout(() => {
        this.loadingInstance.close()
      }, 1000)
    },
    // 以下是附件上传
    handleUploadClick() {
      if (this.roles.includes('院级教师') && (this.infoview1.projectState === '在研待院审核' || this.infoview1.projectState === '在研待校审核' || this.infoview1.projectState === '结题待院审核' || this.infoview1.projectState === '结题待校审核' || this.infoview1.projectState === '结题')) {
        this.$message.error('当前状态不可上传')
      }
    },
    beforeFileUpload(file) {
      if (this.roles.includes('院级教师') && (this.infoview1.projectState === '在研待院审核' || this.infoview1.projectState === '在研待校审核' || this.infoview1.projectState === '结题待院审核' || this.infoview1.projectState === '结题待校审核' || this.infoview1.projectState === '结题')) {
        this.$message.error('当前状态不可上传')
        return false
      }
      return true
    },
    handleFileSuccess(res, file, fileList) {
      this.fileForm.filename = file.name
      this.fileForm.filesize = file.size
      // 处理文件URL，确保正确存储相对路径
      let fileUrl = res.data
      if (fileUrl.startsWith(this.$FILE_PATH)) {
        // 去除 FILE_PATH 前缀，保留相对路径
        fileUrl = fileUrl.replace(this.$FILE_PATH, '')
      }
      // 确保路径以 / 开头
      if (!fileUrl.startsWith('/')) {
        fileUrl = '/' + fileUrl
      }
      this.fileForm.fileurl = fileUrl
      this.commit_file()
    },
    commit_file() {
      file_add(this.fileForm).then(response => {
        if (response.code === 200) {
          Message.success('上传成功')
          this.fetchFileData()
        }
      })
    },
    fetchFileData() {
      this.fileListLoading = true
      get_file(this.fileForm.tregistrationID).then(response => {
        if (response.code === 200) {
          this.fileList = response.data
          this.fileListLoading = false
        }
      })
    },
    downloadFile(row) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      // 确保文件路径正确拼接，处理fileupload文件夹的路径
      let fileUrl = row.fileurl
      if (!fileUrl.startsWith('https')) {
        // 如果不是完整URL，则拼接FILE_PATH
        if (fileUrl.startsWith('/')) {
          fileUrl = this.$FILE_PATH + fileUrl
        } else {
          fileUrl = this.$FILE_PATH + '/' + fileUrl
        }
      }
      a.href = fileUrl
      a.target = '_blank'
      a.dispatchEvent(event)
    },
    deleteFile(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      file_delete(row.fileid).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetchFileData()
        }
      })
    },
    // 以下是分数量化
    fetchSourceData() {
      this.sourceListLoading = true
      getQulification(this.thesis_source_form.projectID).then(response => {
        if (response.code === 200) {
          this.sourceList = response.data
          this.sourceListLoading = false
          this.thesis_source_form.manualScoreMode = response.data[0].manualScoreMode === 'true'
        }
      })
    },
    fetchCascadingData() {
      if (this.source_options.length === 0) {
        const options = {
          target: '.el-cascader__dropdown', // 自定义的类名
          lock: true,
          text: '拼命加载中...'
        }
        this.$nextTick(() => {
          this.sourceCascaderLoading = this.$loading(options)
          getCascadingData().then(response => {
            if (response.code === 200) {
              this.source_options = response.data[0].children
              this.sourceCascaderLoading.close()
            }
          })
          setTimeout(() => {
            this.sourceCascaderLoading.close()
          }, 10000)
        })
      }
    },
    fetchCascadingProjectSourceUnitData() {
      if (this.projectSourceUnit_options.length === 0) {
        getCascadingProjectSourceUnitData().then(response => {
          if (response.code === 200) {
            this.projectSourceUnit_options = response.data
          }
        })
      }
    },
    fetchSecondUnitData() {
      if (this.secondUnit_options.length === 0) {
        getSecondUnitData().then(response => {
          if (response.code === 200) {
            this.secondUnit_options = response.data
          }
        })
      }
    },
    fetchNationalEconomyData() {
      this.SelectLoading = true
      getNationalEconomyData().then(response => {
        if (response.code === 200) {
          this.nationalEconomy_options = response.data
          this.SelectLoading = false
        }
      })
    },
    cascaderhandleChange() {
      this.thesis_source_form.type2ID = this.thesis_source_form.source_cascader_value[0]
    },
    addSource() {
      // 重复提交校验
      if (this.sourceList.length !== 0) {
        Message.warning('已量化')
        return
      }
      // 自动计分模式下的选择类型判空验证
      if (this.thesis_source_form.manualScoreMode === false) {
        if (!this.thesis_source_form.source_cascader_value || this.thesis_source_form.source_cascader_value.length === 0) {
          Message.error('请选择类型')
          return
        }
      }
      // 判空处理
      if (this.thesis_source_form.manualScoreMode === false) {
        const fundsValue = this.thesis_source_form.funds
        if (!/^\d+(\.\d{1,2})?$/.test(fundsValue)) {
          Message.error('到账经费只能输入两位小数')
          return
        }
        if (!fundsValue || fundsValue.toString().trim() === '') {
          Message.error('到账经费不能为空')
          return
        }
      } else {
        // 手动填分模式的判空验证
        if (!/^\d+(\.\d{1,2})?$/.test(this.thesis_source_form.finalValue)) {
          Message.error('最终分数只能输入两位小数')
          return
        }
        if (!this.thesis_source_form.Note || this.thesis_source_form.Note.toString().trim() === '') {
          Message.error('算分详情不能为空')
          return
        }
      }
      addQulification(this.thesis_source_form).then(response => {
        if (response.code === 200) {
          Message.success('添加成功')
          this.fetchSourceData()
          this.fetchOneData()
          this.fetch_thesis_author()
        }
      })
    },
    delete_thesis_source(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      deleteQulification(row.projectQualificationID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetchSourceData()
          this.fetchOneData()
          this.fetch_thesis_author()
        }
      })
    },
    // // 项目类别下拉框
    // fetchProjectCateData() {
    //   this.SelectLoading = true
    //   getProjectCate().then(response => {
    //     const dataData = response.data
    //     this.projectCate_options = this.convertToCascaderData_projectCate(dataData)
    //     this.SelectLoading = false
    //   }).catch(error => {
    // 获取项目类别数据失败处理
    //     this.SelectLoading = false
    //   })
    // },
    convertToCascaderData_projectCate(data) {
      const map = {}
      data.forEach(item => {
        // 第一级
        if (!map[item.papertype1]) {
          map[item.papertype1] = {
            value: item.papertype1,
            label: item.papertype1,
            children: []
          }
        }
        // 第二级
        const firstLevel = map[item.papertype1]
        if (!firstLevel.children.find(child => child.value === item.papertype2)) {
          firstLevel.children.push({
            value: item.papertype2,
            label: item.papertype2,
            children: []
          })
        }
        // 第三级
        const secondLevel = firstLevel.children.find(child => child.value === item.papertype2)
        if (!secondLevel.children.find(child => child.value === item.papertype3)) {
          secondLevel.children.push({
            value: item.papertype3,
            label: item.papertype3
          })
        }
      })
      return Object.values(map)
    }
  }
}
</script>

<style lang="scss">
.el-form{
  margin-left: 40px;
  .el-input,.el-select{
    width: 300px;
  }
}
.el-tag + .el-tag {
  margin: 10px 10px;
}
.margin-top {
  margin-top: 50px;
}
@media screen and (max-width:600px) {
  .el-dialog{
    width: 100% !important;
  }
  .el-form{
    margin-left: 25px;
  }
}
.el-cascader__dropdown {
  position: fixed !important;
}
</style>

<style lang="scss" scoped>
::v-deep .cascader .el-input,::v-deep .cascader .el-select {
    width: 300px !important;
}
</style>
